/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cassys.typeConverters;

import cassys.domain.classManagement.Lecture;
import com.opensymphony.xwork2.conversion.TypeConversionException;
import java.util.Map;
import org.apache.struts2.util.StrutsTypeConverter;

/**
 *
 * @author User
 */
public class LectureTypeConverter extends StrutsTypeConverter {

    public Object convertFromString(Map context, String[] values, Class toClass) {


        /* 
         * For this simple converter, we assume that only one value was passed in. 
         * Thus, we take only the first element in the array of parameter values.
         */
        String userString = values[0];
        Lecture lecture = new Lecture(values[0]);
        return lecture;
    }

    public String convertToString(Map context, Object o) {

        Lecture lecture = (Lecture) o;

        return lecture.getName();
    }
}